class CourseResource {
  String id;
  String courseId;
  String idInfo;
  String name;
  String resourceUrl;
  ResourceType type;
  ResourceStatus status;
  int courseTime;
  int learnTime;
  int score;
  bool learning;

  CourseResource({
    this.id,
    this.courseId,
    this.idInfo,
    this.name,
    this.resourceUrl,
    this.type,
    this.status,
    this.courseTime,
    this.learnTime,
    this.score,
    this.learning,
  });

  factory CourseResource.fromJson(Map<String, dynamic> json) {
    return CourseResource(
      id: json['id'],
      courseId: json['courseId'],
      idInfo: json['idInfo'],
      name: json['name'],
      resourceUrl: json['resourceUrl'],
      type: ResourceType.values[json['type']],
      status: ResourceStatus.values[json['status']],
      courseTime: json['courseTime'] ?? 0,
      learnTime: json['learnTime'] ?? 0,
      score: json['passMark'] ?? 0,
      learning: false,
    );
  }
}

enum ResourceStatus {
  NotStarted,
  Learning,
  Completed,
}

enum ResourceType {
  None,
  Picture,
  Video,
  Document,
  Homework,
  Exam,
}
